//
//  VMCBaseDomain.m
//  vmcshop
//
//  Created by bigknife on 14-10-10.
//  Copyright (c) 2014年 idongler. All rights reserved.
//

#import "VMCBaseDomain.h"
#import "RMMapper.h"

@implementation VMCBaseDomain
-(id) initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    if (self) {
        if (dict && dict != (id)[NSNull null]) {
            //遍历一遍value，如果是NSNull null 则设置为nil
            NSArray *keys = [dict allKeys];
            NSMutableDictionary *tmp = [[NSMutableDictionary alloc]init];

            for (id key in keys) {
                id value = [dict objectForKey:key];
                if (value != (id)[NSNull null]) {
                    [tmp setObject:value forKey:key];
                }
            }
            self = [RMMapper populateObject:self
                             fromDictionary:tmp];
        }
    }
    return self;
}
@end
